// 常量定义

// 用户角色
export const USER_ROLES = {
  ADMIN: 'ADMIN',
  PRODUCT_MANAGER: 'PRODUCT_MANAGER',
  TEST_MANAGER: 'TEST_MANAGER',
  TESTER: 'TESTER',
  DEVELOPER: 'DEVELOPER',
  VIEWER: 'VIEWER'
}

// 用户状态
export const USER_STATUS = {
  ENABLED: 1,
  DISABLED: 0
}

// 产品状态
export const PRODUCT_STATUS = {
  ENABLED: 1,
  DISABLED: 0
}

// 测试申请单状态
export const APPLICATION_STATUS = {
  PENDING: 0,
  APPROVED: 1,
  REJECTED: 2,
  CANCELLED: 3
}

// 测试任务状态
export const TEST_STATUS = {
  PENDING: 0,
  IN_PROGRESS: 1,
  COMPLETED: 2,
  ABORTED: 3
}

// 缺陷状态
export const DEFECT_STATUS = {
  NEW: 0,
  ASSIGNED: 1,
  IN_PROGRESS: 2,
  FIXED: 3,
  VERIFIED: 4,
  REJECTED: 5,
  CLOSED: 6
}

// 缺陷严重程度
export const DEFECT_SEVERITY = {
  CRITICAL: 0,
  HIGH: 1,
  MEDIUM: 2,
  LOW: 3,
  TRIVIAL: 4
}

// 测试类型
export const TEST_TYPES = [
  '功能测试',
  '性能测试',
  '安全测试',
  '回归测试',
  '兼容性测试',
  '其他测试'
]

// HTTP状态码
export const HTTP_STATUS = {
  OK: 200,
  CREATED: 201,
  ACCEPTED: 202,
  NO_CONTENT: 204,
  BAD_REQUEST: 400,
  UNAUTHORIZED: 401,
  FORBIDDEN: 403,
  NOT_FOUND: 404,
  METHOD_NOT_ALLOWED: 405,
  CONFLICT: 409,
  INTERNAL_SERVER_ERROR: 500,
  BAD_GATEWAY: 502,
  SERVICE_UNAVAILABLE: 503,
  GATEWAY_TIMEOUT: 504
}

// 响应状态码
export const RESPONSE_CODE = {
  SUCCESS: 200,
  BAD_REQUEST: 400,
  UNAUTHORIZED: 401,
  FORBIDDEN: 403,
  NOT_FOUND: 404,
  INTERNAL_ERROR: 500,
  VALIDATION_ERROR: 422
}

// 分页大小选项
export const PAGE_SIZE_OPTIONS = [10, 20, 50, 100]

// 默认分页大小
export const DEFAULT_PAGE_SIZE = 10

// 默认当前页码
export const DEFAULT_CURRENT_PAGE = 1

// 最大文件大小（字节）
export const MAX_FILE_SIZE = 10 * 1024 * 1024 // 10MB

// 支持的文件类型
export const SUPPORTED_FILE_TYPES = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'zip', 'rar']

// 日期格式化
export const DATE_FORMATS = {
  DATE: 'YYYY-MM-DD',
  TIME: 'HH:mm:ss',
  DATE_TIME: 'YYYY-MM-DD HH:mm:ss',
  TIME_ZONE: 'YYYY-MM-DDTHH:mm:ss.SSSZ'
}

// 存储键名
export const STORAGE_KEYS = {
  TOKEN: 'token',
  USER_INFO: 'userInfo',
  PERMISSIONS: 'permissions',
  LANGUAGE: 'language',
  THEME: 'theme',
  LAST_LOGIN_TIME: 'lastLoginTime'
}

// 本地存储类型
export const STORAGE_TYPES = {
  LOCAL: 'local',
  SESSION: 'session'
}

// API路径前缀
export const API_PREFIX = '/api'

// 缓存键前缀
export const CACHE_KEY_PREFIX = 'test_platform_'

// 正则表达式
export const REGEX = {
  MOBILE: /^1[3-9]\d{9}$/,
  EMAIL: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
  ID_CARD: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
  URL: /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,
  IP: /^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
  INTEGER: /^-?\d+$/, 
  DECIMAL: /^-?\d+(\.\d+)?$/,
  POSITIVE_INTEGER: /^\d+$/, 
  POSITIVE_DECIMAL: /^\d+(\.\d+)?$/,
  CHINESE: /^[\u4e00-\u9fa5]+$/,
  ENGLISH: /^[a-zA-Z]+$/,
  ENGLISH_NUMBER: /^[a-zA-Z0-9]+$/,
  PASSWORD: /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,20}$/,
  USERNAME: /^[a-zA-Z][a-zA-Z0-9_]{2,19}$/,
  DATE: /^\d{4}-\d{2}-\d{2}$/,
  TIME: /^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/,
  DATE_TIME: /^\d{4}-\d{2}-\d{2} ([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/
}